/**********************************************************************
Name:  Batch_ServiceCaseNoticeProduct
======================================================
在个案到期日期之前要通知产品培训部需要提前30天 运行                                              
-------                                                            
VERSION  AUTHOR            DATE              DETAIL                                
1.0 -    Jerry            2016-11-30         Created
***********************************************************************/
global class Batch_ServiceCaseNoticeProduct {

}/*implements Database.Batchable<sObject>, Database.Stateful {
	public Integer CurYear{get;set;}
	public Integer CurMonth{get;set;}
	public Id SerRetp{get;set;}
	public Batch_ServiceCaseNoticeProduct()
	{
		RecordType rd=[select id,DeveloperName from RecordType where DeveloperName='ServicePlanCase'];
		SerRetp=rd.Id;
		Date dt=Date.today().addMonths(1);
		CurYear=dt.year();
		CurMonth=dt.month();
	}
	
	global Database.QueryLocator start( Database.BatchableContext BC ) {
        return Database.getQueryLocator([select id,Subject,Owner.Email,Owner.Name,
        Dept__c,Year__c,Month__c,RecordTypeId
        from Case where RecordTypeId=:SerRetp and Year__c=:CurYear and Month__c=:CurMonth
        and Dept__c like '%产品培训部%']);
    }
 
    global void execute(Database.BatchableContext info, List<sObject> scope) {   
    		
            List<Task> list_tk=new List<Task>();
            for(Sobject sc:scope)
            {
                
                Case ca=(Case)sc;
                Task tk=new Task();
                tk.WhatId=sc.Id;
                tk.ActivityDate=Date.valueOf(String.valueOf(Integer.valueOf(ca.Year__c))+'-'+String.valueOf(Integer.valueOf(ca.Month__c))+'-'+'1');
                tk.OwnerId=ca.OwnerId;
                tk.IsService__c=true;
                tk.Subject=ca.Subject;
                list_tk.add(tk);
                
            }
            
            insert list_tk;
            
            
            
              
           
    } 
    
    global void finish(Database.BatchableContext info) {
    	
    	
    	
    }
}*/